/*
 * MemoryCard.java
 *
 * Created on 3 maggio 2007, 21.56
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package alecava;
import java.io.*;
/**
 *
 * @author alecava
 */
public class MemoryCard {
    
    public static boolean salva(String nomeFile, Object o){
        try{
            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(nomeFile)));
            out.writeObject(o);
            out.flush();
            out.close();
            return true;
        } catch (IOException e){
            return false;
        }
    }
    
    public static Object carica(String nomeFile){
        try{
            ObjectInputStream in = new ObjectInputStream(new FileInputStream(new File(nomeFile)));
            Object o = in.readObject();
            in.close();
            return o;
        } catch (IOException e){
            return null;
        } catch (ClassNotFoundException e){
            return null;
        }
    }
    
}
